Skip to content

fix(logger): keep internal diagnostics in the active file after rotation - #3126

Merged
Pangjiping merged 1 commit into
opensandbox-group:mainfrom
cwj2001:fix/logger-share-rotating-writer
Nov 26, 2026
Merged

Pangjiping merged 1 commit into
opensandbox-group:mainfrom
cwj2001:fix/logger-share-rotating-writer

Conversation

@cwj2001

@cwj2001 cwj2001 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

With one configured log file, Zap's internal error output defaults to the same path as ordinary output. Each route previously opened its own rotating writer. Once both writers were open, rotation on the ordinary route could leave internal diagnostics going to the renamed backup instead of the active file. Repeating an output path could also cause the writers to undercount the bytes written to that file.

Reuse the writer for each identical path string within a logger instance. This shares the file handle and size counter without removing any configured copies. It does not change rotation limits, resolve filesystem aliases, or introduce a dependency.

Testing

The regression uses real files and a failing additional Zap core. Before the fix, both internal diagnostics landed in the backup in the single-path case; the duplicate-path case failed to rotate. Both cases now pass. From components/internal, with Go 1.26.11:

go test -mod=readonly -race -count=1 ./logger
go vet -mod=readonly ./logger

Resolve each configured path once per logger and keep the original route lists. This keeps Zap internal diagnostics in the active file and accounts for duplicate writes against one size limit.

Signed-off-by: cwj2001 <74065082+cwj2001@users.noreply.github.com>
@github-actions github-actions Bot added component/egress component/ingress size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T06:30:48.221892Z 942c7b9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Pangjiping Pangjiping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Pangjiping
Pangjiping merged commit faa30a9 into opensandbox-group:main Nov 26, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/egress component/ingress size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants